Skip to content

Conversation

@Pennycook
Copy link
Contributor

Related issues

Proposed changes

  • Replace the concept of "code utilization" with "coverage" and "average coverage".
  • Simplify the FileTree output by focusing in "coverage" metrics and removing redundant information.
  • Add a description of "coverage" to the documentation, alongside "code divergence".

The new report output is much more readable than the old one:

image


I've opened this as a draft to ensure that we don't accidentally merge it before #158, but I think the functionality is ready for review.

@Pennycook Pennycook added documentation Improvements or additions to documentation ux Issues and PRs pertaining to user experience labels Jan 28, 2025
@Pennycook Pennycook added this to the 2.0.0 milestone Jan 28, 2025
@Pennycook Pennycook requested a review from laserkelvin January 28, 2025 12:07
@Pennycook Pennycook marked this pull request as ready for review February 19, 2025 17:02
Presenting the amount of code used by all platforms as "coverage" is more
aligned with how we describe CBI's functionality elsewhere.

Signed-off-by: John Pennycook <[email protected]>
Small refactoring to enable later re-use.

Signed-off-by: John Pennycook <[email protected]>
This has several advantages:
- It wastes less whitespace than printing two SLOC counts.
- The reader doesn't have to perform division to calculate coverage.
- We can easily color-code coverage to highlight good/bad values.

Signed-off-by: John Pennycook <[email protected]>
Computing coverage relative to a set of platforms enables the function to be
used in more contexts.

Signed-off-by: John Pennycook <[email protected]>
Signed-off-by: John Pennycook <[email protected]>
- Mention "platform coverage" in README and home page.
- Add a description of "platform coverage" to the specialization page.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook
Copy link
Contributor Author

The merge was too complicated for GitHub (because a file that was modified elsewhere was deleted here) so I had to rebase. @laserkelvin, this is safe to review now.

Copy link

@laserkelvin laserkelvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a stylistic comment on a docstring.

I really liked the write-up in specialization.rst!

platforms: set[str] | None = None,
) -> float:
"""
Compute the average percentage of lines in `setmap` required by each

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a minor rephrasing - not sure if it's just my brain but when I mention reductions in text I try and move it away from the original quantity and be explicit about what the reduction is over.

In this case, "...percentage of lines in setmap required by each platform in the supplied platforms set, **averaged over the set of platforms." Similar to how you've written it for the output description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke my brain a little bit. 😆

I think which form I'd prefer to use depends on context. I'd definitely say something like "temperature, averaged over volume", but in this case I think it's important to emphasize at the beginning of the sentence that what we are returning is an average .

I've tried to split the difference, and made two changes. In e45edc6, I broke down the behavior of the function to explain what we're computing:

Computes the coverage for each platform in the supplied `platforms` set
(by calling :py:func:`coverage` for each platform), then returns the
average (mean) of these values.

...and then in 29fc127 I added the missing Returns sections, with shorter sentences that are hopefully easier to parse, e.g.:

The average amount of code used by each platform, as a percentage.

@Pennycook Pennycook merged commit 00f4a4f into P3HPC:main Feb 27, 2025
4 checks passed
@Pennycook Pennycook deleted the metric-rework branch February 27, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation ux Issues and PRs pertaining to user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve code utilization functionality

2 participants